package com.sunplus.common.core.ossstorage.aliyunstorage;

import com.aliyun.oss.OSS;
import com.aliyun.oss.model.OSSObject;
import com.sunplus.common.core.ossstorage.inteface.IStorageFolder;

import java.util.Date;

/**
 * @author shaoqi
 * @ClassName AliyunOssFolder
 * @Description TODO
 * @date 2021/2/9 0009
 */
public class AliyunOssFolder implements IStorageFolder {

    private OSS ossClient;

    private OSSObject oss;

    private String rootPath;

    public AliyunOssFolder(OSS ossclient, OSSObject oss, String rootpath) {
        this.ossClient = ossclient;
        this.oss = oss;
        this.rootPath = rootpath;
    }


    @Override
    public String getPath() {
        return oss.getKey();
    }

    @Override
    public String getName() {
        return AliyunOssUtil.Util.getEntityName(oss.getKey());
    }

    @Override
    public long getSize() {
        return oss.getObjectMetadata().getContentLength();
    }

    @Override
    public Date getLastUpdated() {
        return oss.getObjectMetadata().getLastModified();
    }

    @Override
    public IStorageFolder getParent() {
        return null;
    }
}
